package com.hehao.consumer;

import com.hehao.config.RabbitConfig;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

/**
 * 通配符类型
 * @Author Damon
 * @Date 2024/7/30 10:00
 */
@Slf4j
@Component
public class TopicCustomer {

//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "topicQueue1"),
//            exchange = @Exchange(value = "testTopicExchange", type = ExchangeTypes.TOPIC),
//            key = "topic.*"// `*`：匹配一个单词，就只有一个单词
//    ))
@RabbitListener(queues = RabbitConfig.QUEUE_1)
    public void listener1(String msg) {
        log.info("listener1-->接收消息【通配符模式】：{}", msg);
    }

//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "topicQueue2"),
//            exchange = @Exchange(value = "testTopicExchange", type = ExchangeTypes.TOPIC),
//            key = "topic.#"// `#`：匹配一个或多个词
//    ))
    @RabbitListener(queues = RabbitConfig.QUEUE_2)
    public void listener2(String msg) {
        log.info("listener2-->接收消息【通配符模式】：{}", msg);
    }

//    @RabbitListener(bindings = @QueueBinding(
//            value = @Queue(value = "topicQueue3"),
//            exchange = @Exchange(value = "testTopicExchange", type = ExchangeTypes.TOPIC),
//            key = "topic.y.#"// `#`：匹配一个或多个词
//    ))
    @RabbitListener(queues = RabbitConfig.QUEUE_3)
    public void listener3(String msg) {
        log.info("listener3-->接收消息【通配符模式】：{}", msg);
    }
}
